/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.marcelo.comun.notificaciones;

import java.awt.event.ActionListener;
import javax.swing.Icon;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.Notification;
import org.openide.awt.NotificationDisplayer;
import org.openide.awt.StatusDisplayer;
import org.openide.util.ImageUtilities;

/**
 *
 * @author marcelo
 * La idea de esta clase es la de mostrar notificaciones a los usuarios
 * sobre los diversos eventos que suceden en el sistema
 */
public class Notificaciones {
    
    public static final int DEFAULT_MESSAGE = NotifyDescriptor.DEFAULT_OPTION;
    public static final int INFORMATION_MESSAGE =NotifyDescriptor.INFORMATION_MESSAGE ;
    public static final int WARNING_MESSAGE = NotifyDescriptor.WARNING_MESSAGE;
    public static final int ERROR_MESSAGE = NotifyDescriptor.ERROR_MESSAGE;
    public static final int QUESTION_MESSAGE = NotifyDescriptor.QUESTION_MESSAGE;
    public static final int YES_NO_MESSAGE = NotifyDescriptor.YES_NO_OPTION;
    
    //Constantes
    public static final Object YES_OPTION = NotifyDescriptor.YES_OPTION;
    public static final Object CANCEL_OPTION = NotifyDescriptor.CANCEL_OPTION;
    
    private static final Icon DEFAULT_ICON = ImageUtilities.loadImageIcon("org/marcelo/agro/recursos/informacion_24x24.png", true);
    private static final int  DEFAULT_PRIORITY = 0;
    
    public static Object showMessageBox(Integer tipo, String message) {
        NotifyDescriptor nd = new NotifyDescriptor.Message(message ,tipo );
        return DialogDisplayer.getDefault().notify(nd);
    }
    
    public static Object showMessageBox(String message) {
        return showMessageBox(DEFAULT_MESSAGE, message);
    }
    
    public static Object showConfirmationMessage(String message, String title) {
         NotifyDescriptor nd = new NotifyDescriptor.Confirmation(message , title);
        return DialogDisplayer.getDefault().notify(nd);
    }
    
    /**Metodos para mostrar notificaciones
     * 
     * @param title
     * @param icon
     * @param shortDescription
     * @param al 
     */
    public static void notificar(String title, Icon icon, String shortDescription,ActionListener al) {
         Notification noti = NotificationDisplayer.getDefault().notify(title, icon, shortDescription, al);
    }
    
    public static void notificar(String title, String shortDescripcion){
        notificar(title, DEFAULT_ICON, shortDescripcion, null);
    }
    
    /**
     * Metodos para mostrar en el status
     */
    private static int DEFAULT_IMPORTANCE = 200;
    public static void statusDisplay(String message) {
        StatusDisplayer.getDefault().setStatusText(message,DEFAULT_IMPORTANCE); 
    }
    public static void statusDisplay(String message, int importance) {
        StatusDisplayer.getDefault().setStatusText(message,DEFAULT_IMPORTANCE); 
    }
    
}
